from .PlaceholderUtils import *


class Chunker:
    def __init__(self):
        pass

    def run(self, text):
        lines = text.split("\n")
        chunks = []
        for line in lines:
            if is_placeholder(line.strip()) or len(line.strip()) == 0:
                if len(chunks) > 0:
                    chunks[-1] += "\n" + line
                    if line == "":
                        chunks[-1] += "\n"
                else:
                    chunks.append(line)
            else:
                chunks.append(line)
        return chunks
